package nc.hw;

public class HJ23 {

    private static String lessChars(String word) {
        int[] timesOfChar = new int[26];
        char[] chars = word.toCharArray();
        for (char aChar : chars) {
            timesOfChar[aChar - 'a'] += 1;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < 26; i++) {
            if (timesOfChar[i] != 0 && timesOfChar[i] < min) {
                min = timesOfChar[i];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (char c : word.toCharArray()) {
            if (timesOfChar[c - 'a'] != min) {
                sb.append(c);
            }
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(lessChars("aabcddd"));
    }

}
